package com.hyhy.hycloud.uaa.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author Xuegui Yuan
 * @date 2018-12-13
 */
@Configuration
public class UserInfoResourceConfig {

    @Autowired
    private RestTemplateBuilder builder;

    @Value("${uaa.user-info.url}")
    private String uaaUserInfoUrl;

    @Bean
    UserInfoResourceService userInfoService() {
        return new UserInfoResourceService(restTemplate(), uaaUserInfoUrl, new ObjectMapper());
    }

    @Bean
    public RestTemplate restTemplate() {
        return builder.build();
    }
}
